<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>
import { getRouteDocs } from '@/api/system/manualDescription'
import { MANAGEMENT } from '@haisum-cloud/ui-components/packages/utils'
import handbookMixin from '@haisum-cloud/ui-components/packages/mixin/handbook'
export default {
  name: 'App',
  mixins: [handbookMixin],
  metaInfo() {
    return {
      title: this.$store.state.settings.dynamicTitle && this.$store.state.settings.title,
      titleTemplate: title => {
        return title ? `${title} - ${process.env.VUE_APP_TITLE}` : process.env.VUE_APP_TITLE
      }
    }
  },
  data() {
    return {
      handbookType: MANAGEMENT,
      fetchDataFn: getRouteDocs
    }
  },
  created() {
    // // 在页面刷新时将vuex里的信息保存到localStorage里
    window.addEventListener('beforeunload', () => {
      /* 关闭问题列表窗口*/
      if (window.childIssueList !== undefined && !window.childIssueList.closed) {
        window.childIssueList.close()
      }
    })
    // 在页面加载时读取localStorage里的状态信息
    localStorage.getItem('messageStore') && this.$store.dispatch('page/addPageParmas', JSON.parse(localStorage.getItem('messageStore')))
  }
}
</script>
